Ext.ns('ru.proburo.oms.catalog.dao');

/**
 * ru.proburo.oms.catalog.dao.ItemStore
 * @extends Ext.data.Store
 */
if(true === Ext.isAir)
{
	ru.proburo.oms.catalog.dao.ItemStore = Ext.extend(Ext.data.SQLiteStore, {
		constructor: function(config)
		{
			config = config || {};
			
			Ext.applyIf(config, {
				dbFile:    ru.proburo.oms.Constants.DATABASE,
				tableName: 'CatalogItemView',
				key: 	   'id',
				
				fields: ru.proburo.oms.catalog.entities.Item,
				
				autoSave:   false,
				remoteSort: true
			});
			
			ru.proburo.oms.catalog.dao.ItemStore.superclass.constructor.call(this, config);
		}
	});
}
else
{
	ru.proburo.oms.catalog.dao.ItemStore = Ext.extend(Ext.data.Store, {
		constructor: function(config)
		{
			config = config || {};
			
			Ext.applyIf(config, {
				url:    '/services/catalog/item/list.json',
				fields: ru.proburo.oms.catalog.entities.Item,            
				reader: new Ext.data.JsonReader({
					fields: ru.proburo.oms.catalog.entities.Item,
					
					idProperty:      'id',
					root:            'items',
					successProperty: 'success',
					totalProperty:   'totalCount'
				}),
				
				autoSave:   false,
				remoteSort: true
			});
			
			ru.proburo.oms.catalog.dao.ItemStore.superclass.constructor.call(this, config);
		}
	});
}